#pragma once

#include "SocketShared.h"

class ServerSocket : public ISimpleChannel
{
    Q_OBJECT

public:
    ServerSocket(const SocketSettings& settings, const QString& name = "");
	
    virtual bool       Open();
    virtual bool       IsOpened();
    virtual void       Close();
    virtual void       Reset();

    virtual unsigned   DataAvailable();
    virtual QString    LastError();
    virtual QString    Info();

    virtual QByteArray Receive(unsigned size);
    virtual unsigned   Send(const QByteArray& data); 

private slots:
    void ClientConnected();

private:
    std::tr1::shared_ptr<QTcpServer> _server;
    QTcpSocket*                      _socket;
    SocketSettings                   _settings;
};